package com.zxtc.wh.dao;

import com.zxtc.wh.pojo.resource.ResourcePojo;
import com.zxtc.wh.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.*;

import static org.junit.Assert.*;

public class ResourceDaoImplTest2 {
    private static SqlSession sqlSession;
    private static IResourceDao dao;


    @BeforeClass
    public  static void setUp() throws Exception {
//        sqlSession = MybatisUtils.getInstance();
        sqlSession = MybatisUtils.getDebugInstance();
//        dao = new ResourceDaoImpl(sqlSession);
        dao = sqlSession.getMapper(IResourceDao.class);
    }

    @AfterClass
    public static void tearDown() throws Exception {
        sqlSession.close();
    }

//    @Test
//    public void create() throws Exception {
//
//    }
//
//
//    @Test
//    public void updateOrCreate() throws Exception {
//
//    }
//
//    @Test
//    public void update() throws Exception {
//
//    }

    @Test
    public  void insert() throws Exception {
        ResourcePojo pojo = new ResourcePojo();
//        pojo.set

    }

    @Test
    public void isExists() throws Exception {
        //默认存在
        Boolean exists = dao.isExists(1L);
        assertTrue(exists);

        Boolean exists1 = dao.isExists(1L);
        Boolean exists2 = dao.isExists(0L);
        Boolean exists3 = dao.isExists(-1L);
    }

    @Test
    public void getInstance() throws Exception {
        Object o = sqlSession.selectOne("com.zxtc.wh.dao.IResourceDao.getInstance", 1L);

        ResourcePojo pojo = dao.getInstance(1L);
        assertNotNull(pojo);
    }


}